<!DOCTYPE html>
<html lang="en" ng-app="khj">
<head>
    <meta charset="UTF-8">
    <script src="angular.js"></script>
    <title>angular</title>
</head>
<clock></clock>
<body>
<script>
    var app = angular.module('khj',[]);
    app.directive('clock',function () {
        return{
            restrict:"E",
            replace:true,
            template:"<div class='clock'></div>",
            link:function (scope,element,attrs) {
//                console.log(scope)
//                console.log(element)
//                console.log(attrs)
    setInterval(function () {
                    var date = new Date();
                    element.text(date.toString());
                },1000);

            }
        }
    })
//    手动启动
//    angular.bootstrap(document,'khj');

</script>
</body>
</html>